home *** CD-ROM | disk | FTP | other *** search
- package Forms
- {
- import flash.display.*;
- import flash.events.*;
- import flash.geom.*;
- import flash.system.*;
- import flash.text.*;
-
- [Embed(source="/_assets/assets.swf", symbol="Forms.ProfileCreatePopupForm")]
- public class ProfileCreatePopupForm extends CluelessBaseForm
- {
-
-
- private var tmpText:String;
-
- public var _tfTextName:TextField;
-
- public var _ErrorMessage_mc:MovieClip;
-
- public var _bBack:SimpleButton;
-
- public var _bCreate:SimpleButton;
-
- public function ProfileCreatePopupForm()
- {
- super();
- setBackButton(_bBack);
- installMouseOverSound(_bBack);
- _tfTextName.alwaysShowSelection = true;
- tmpText = "";
- _tfTextName.text = "";
- _tfTextName.addEventListener(TextEvent.TEXT_INPUT,textInputCapture);
- _ErrorMessage_mc.visible = false;
- _bCreate.addEventListener(MouseEvent.CLICK,onCreateClicked,false,0,true);
- _ErrorMessage_mc.addEventListener(MouseEvent.CLICK,onErrorClicked,false,0,true);
- }
-
- protected function onCreateClicked(param1:MouseEvent) : void
- {
- if(_tfTextName.text.length > 0)
- {
- if(_tfTextName.text.charCodeAt(0) == 32)
- {
- _ErrorMessage_mc._txtError.text = "Please start with Alphanumeric characters";
- _ErrorMessage_mc.visible = true;
- }
- else if(Profile.getProfile(_tfTextName.text) == null)
- {
- if(Profile.ProfileList.length == 0)
- {
- Storage.getInstance().newProfile(_tfTextName.text);
- Profile.CurrentProfile = Profile.getProfile(_tfTextName.text);
- Storage.getInstance().saveProfiles();
- }
- else
- {
- Storage.getInstance().newProfile(_tfTextName.text);
- }
- onBack(new MouseEvent(""));
- }
- else
- {
- _ErrorMessage_mc._txtError.text = "Name already exists. Please use another name";
- _ErrorMessage_mc.visible = true;
- }
- }
- }
-
- protected function onErrorClicked(param1:MouseEvent) : void
- {
- _ErrorMessage_mc.visible = false;
- }
-
- override public function onFocus() : void
- {
- super.onFocus();
- _stageCurrent.focus = _tfTextName;
- }
-
- public function textInputCapture(param1:TextEvent) : void
- {
- trace(_tfTextName.textWidth);
- if(_tfTextName.textWidth > 330)
- {
- _tfTextName.maxChars = _tfTextName.length;
- }
- else
- {
- _tfTextName.maxChars = 25;
- }
- }
- }
- }
-